<?php
function findEvent($eventid){
	$c = connect();
	$r = mysql_query("SELECT * FROM events WHERE idevent='".$eventid."'");
	if(mysql_num_rows($r) == 0)
		$r = false;
	else
		$r = true;
	mysql_close($c);
	return $r;
}

function getArticles($all=false){
	$articles = array();
	$c = connect();
	if($all){
		$r = mysql_query("SELECT * FROM 
			(SELECT * FROM submissions 
			WHERE events_idevents='".$_GET['id']."') AS a
			JOIN articles ON articles_idarticles = idarticles"
		);
	}
	else{
		$r = mysql_query("SELECT * FROM 
			(SELECT * FROM submission 
			WHERE events_idevents='".$_GET['id']."' AND status='Published') AS a
			JOIN articles ON articles_idarticles = idarticles"
		);
	}
	while($row = mysql_fetch_assoc($r))
		array_push($articles, $row);
	mysql_close($c);
	return $articles;
}

function submenu($prog=false, $comm=false, $part=false, $mile, $active=null){
	echo '<div class="container submenu">
		<div class="navbar">
		<div class="navbar-inner">
		<ul class="nav">';
	if($part && $mile == 0){
		if($active == "submit")
			echo '<li class="active"><a href="submit.php?id='.$_GET['id'].'">Submit</a></li>';
		else
			echo '<li><a href="submit.php?id='.$_GET['id'].'">Submit</a></li>';
	}
	if($comm && $mile < 2 && $mile > 1){
		if($active == "bid")
			echo '<li><a href="bid.php?id='.$_GET['id'].'">Bid</a></li>';
		else
			echo '<li><a href="bid.php?id='.$_GET['id'].'">Bid</a></li>';
	}
	if($prog && $mile < 3 && $mile > 2){
		if($active == "assign")
			echo '<li><a href="assign.php?id='.$_GET['id'].'">Assign</a></li>';
		else
			echo '<li><a href="assign.php?id='.$_GET['id'].'">Assign</a></li>';
	}
	if($comm && $mile < 3 && $mile > 2){
		if($active == "rate")
			echo '<li><a href="rate.php?id='.$_GET['id'].'">Rate</a></li>';
		else
			echo '<li><a href="rate.php?id='.$_GET['id'].'">Rate</a></li>';
	}
	if($prog && $mile < 4 && $mile > 3){
		if($active == "publish")
			echo '<li><a href="publish.php?id='.$_GET['id'].'">Publish</a></li>';
		else
			echo '<li><a href="publish.php?id='.$_GET['id'].'">Publish</a></li>';
	}
	echo '</ul>';
	if($prog)
		if($active == "settings")
			echo '<ul class="nav pull-right">',
			'<li class="pull-right active"><a href="event_setting.php?id='.$_GET['id'].'">Settings</a></li>',
			'</ul>';
		else
			echo '<ul class="nav pull-right">',
			'<li class="pull-right"><a href="event_setting.php?id='.$_GET['id'].'">Settings</a></li>',
			'</ul>';
	echo "</div></div></div>\n";
}

?>
